import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { viteMockServe } from "vite-plugin-mock";
import { visualizer } from "rollup-plugin-visualizer";
import VueDevTools from "vite-plugin-vue-devtools";
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": "/src",
    },
  },
  plugins: [
    VueDevTools({
      // 启用 Vue DevTools
      componentInspector: true,
      // 将默认编辑器从 VS Code 更改为 WebStorm
      // launchEditor: 'webstorm',
    }),
    vue(),
    viteMockServe({
      mockPath: "./mock/",
    }),
    visualizer({ open: false }),
  ],
  base: "/",
  server: {
    host: "0.0.0.0",
  },
  build: {
    rollupOptions: {
      output: {
        // 分离 CSS 和 JS 文件
        // CSS 文件的输出规则
        chunkFileNames: 'static/js/[name]-[hash].js',
        entryFileNames: 'static/js/[name]-[hash].js',
        assetFileNames: 'static/[name]-[hash][extname]',
      },
    },
  },
});
